package com.tust.app.controller;

import com.tust.app.dao.NewsMapper;
import com.tust.app.domain.News;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;


import java.util.List;

@Controller
public class IndexController {

    //获取NewsMapper对象，之前context.getBean()
//如何再当前获取NewsMapper对象呢
@Autowired
//这是把Spring 容器对象放到变量里去
    private NewsMapper newsMapper;


    //http://localhost:8080/course/test

    @RequestMapping("test")

    public String index(){
        List<News> news=newsMapper.selectAllNews();
        System.out.println(news);
        return "index";

    }


}
